package com.dnjn.happiness.biz.api.factory;

import com.dnjn.happiness.biz.api.RemoteAppraiseService;
import com.dnjn.happiness.biz.api.model.AppraiseModel;
import com.dnjn.happiness.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class RemoteAppraiseFallbackFactory implements FallbackFactory<RemoteAppraiseService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteAppraiseFallbackFactory.class);

    @Override
    public RemoteAppraiseService create(Throwable throwable) {
        log.error("调用沟通服务失败：" + throwable.getMessage());
        return new RemoteAppraiseService() {
            @Override
            public R<List<AppraiseModel>> getAppraiseRecords(Long userId, String time, String source) {
                return R.fail("获取评价信息失败 ：{}" + throwable.getMessage());
            }

            @Override
            public R<Double> getHappinessScoresViewAppriseNew(Long userId, Double base_percent, Double x, String source) {
                return R.fail("获取评价信息失败 ：{}" + throwable.getMessage());
            }
        };
    }
}
